import { alova } from '../../request';

/** get dict list */
export function paginateDict(params?: Api.SearchParams) {
  return alova.Get<Api.Manage.DictList>('/setting/dict/paginate', {
    params
  });
}

export function createDict(data?: Api.Model) {
  return alova.Post<boolean>('/setting/dict/create', data);
}

export function updateDict(data?: Api.Model) {
  return alova.Post<boolean>('/setting/dict/update', data);
}

export function deleteDict(id: number) {
  return alova.Post<boolean>('/setting/dict/delete', { id });
}

export function batchDeleteDict(ids: number[]) {
  return alova.Post<boolean>('/setting/dict/batchDelete', { ids });
}

/**
 * get all dict
 *
 * these dict are all enabled
 */
export function listDict() {
  return alova.Get<Api.Row[]>('/setting/dict/list');
}

/** get dict list */
export function paginateDictItem(params?: Api.SearchParams) {
  return alova.Get<Api.Manage.DictItemList>('setting/dictItem/paginate', {
    params
  });
}

export function createDictItem(data?: Api.Model) {
  return alova.Post<boolean>('/setting/dictItem/create', data);
}

export function updateDictItem(data?: Api.Model) {
  return alova.Post<boolean>('/setting/dictItem/update', data);
}

export function deleteDictItem(id: number) {
  return alova.Post<boolean>('/setting/dictItem/delete', { id });
}

export function batchDeleteDictItem(ids: number[]) {
  return alova.Post<boolean>('/setting/dictItem/batchDelete', { ids });
}

/**
 * get all dict
 *
 * these dict are all enabled
 */
export function listDictItem() {
  return alova.Get<Api.PageRow>('setting/dictItem/list');
}
